﻿using D3StatsClient.Model;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;

namespace D3StatsClient.Converters
{
    public sealed class ItemBackgroundColorConverter : IValueConverter
    {
        public ItemBackgroundColorConverter()
        {
            // set defaults
        }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is ItemQuality))
            {
                return null;
            }

            BrushConverter converter = new BrushConverter();

            ItemQuality qualityLevel = (ItemQuality) value;

            string color = Utility.GetColorForItemQuality(qualityLevel);

                
            Color brushcolor = (Color)ColorConverter.ConvertFromString(color);

            SolidColorBrush scBrush = new SolidColorBrush(brushcolor);
            scBrush.Opacity = 0.3;

            return scBrush;


        }

        public object ConvertBack(object value, Type targetType,
            object parameter, CultureInfo culture)
        {
            return value;
        }
    }
}
